namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update112 : DbMigration
    {
        public override void Up()
        {
            //DropForeignKey("dbo.hrm_ps_absence_rules", "emp_type_seq", "dbo.hrm_ps_employee_types");
            //DropForeignKey("dbo.hrm_ps_absence_rules", "absence_type_seq", "dbo.hrm_ps_absence_types");
            //DropIndex("dbo.hrm_ps_absence_rules", new[] { "emp_type_seq" });
            //DropIndex("dbo.hrm_ps_absence_rules", new[] { "absence_type_seq" });
            RenameColumn(table: "dbo.rule_absence", name: "rule_absence_seq", newName: "rule_seq");
            RenameColumn(table: "dbo.rule_absence", name: "day_limit", newName: "quota_day");
            RenameColumn(table: "dbo.rule_absence", name: "day_limit_full_salary", newName: "quota_salary");
            RenameColumn(table: "dbo.rule_absence", name: "day_limit_half_salary", newName: "quota_half_salary");
            RenameColumn(table: "dbo.rule_absence", name: "time_limit", newName: "quota_count");
            RenameColumn(table: "dbo.rule_absence", name: "day_per_time_limit", newName: "quota_day_count");
            DropTable("dbo.hrm_ps_absence_rules");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.hrm_ps_absence_rules",
                c => new
                    {
                        rule_seq = c.Int(nullable: false, identity: true),
                        emp_type_seq = c.Int(nullable: false),
                        absence_type_seq = c.Int(nullable: false),
                        quota_day = c.Decimal(precision: 18, scale: 2),
                        quota_salary = c.Decimal(precision: 18, scale: 2),
                        quota_count = c.Decimal(precision: 18, scale: 2),
                        quota_day_count = c.Decimal(precision: 18, scale: 2),
                        remarks = c.String(),
                        record_status = c.String(),
                        created_by = c.Int(),
                        created_when = c.DateTime(),
                        updated_by = c.Int(),
                        updated_when = c.DateTime(),
                    })
                .PrimaryKey(t => t.rule_seq);
            
            RenameColumn(table: "dbo.rule_absence", name: "quota_day_count", newName: "day_per_time_limit");
            RenameColumn(table: "dbo.rule_absence", name: "quota_count", newName: "time_limit");
            RenameColumn(table: "dbo.rule_absence", name: "quota_half_salary", newName: "day_limit_half_salary");
            RenameColumn(table: "dbo.rule_absence", name: "quota_salary", newName: "day_limit_full_salary");
            RenameColumn(table: "dbo.rule_absence", name: "quota_day", newName: "day_limit");
            RenameColumn(table: "dbo.rule_absence", name: "rule_seq", newName: "rule_absence_seq");
            CreateIndex("dbo.hrm_ps_absence_rules", "absence_type_seq");
            CreateIndex("dbo.hrm_ps_absence_rules", "emp_type_seq");
            AddForeignKey("dbo.hrm_ps_absence_rules", "absence_type_seq", "dbo.hrm_ps_absence_types", "absence_type_seq", cascadeDelete: true);
            AddForeignKey("dbo.hrm_ps_absence_rules", "emp_type_seq", "dbo.hrm_ps_employee_types", "emp_type_seq", cascadeDelete: true);
        }
    }
}
